home *** CD-ROM | disk | FTP | other *** search
- Path: news.tiac.net!smayo
- From: smayo@tiac.net (Scott Mayo)
- Newsgroups: comp.std.c
- Subject: Is it legal to add 0 to NULL? What about NULL < NULL?
- Date: Sat, 06 Apr 1996 10:02:08 -0500
- Organization: The Internet Access Company
- Message-ID: <ff1d.smail.smayo@tiac.net>
- NNTP-Posting-Host: sunspot.tiac.net
-
- I ask because a standard trick for walking an array A of size S is:
-
- Thing *a = A;
- Thing *fence = a + S;
- for (; a < fence; ++a)
- /* use a */;
-
- but in my case, if S happens to be 0, a will start out NULL. This makes we
- worry about both the value of fence, and, if that works, the behaviour
- of (a < fence), which I hope is (NULL < NULL), which I hope the standard
- blesses as reliably false, but I have this feeling that it won't.
-
- I know I can use int i; for (i = 0; i < S; ++i) but I was
- hoping to avoid the extra math at array dereference time. I know
- I can preface the whole thing with if (a != NULL) but the fun of
- a standard is knowing what you can get away with. :)
-
- Comments?
-